<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><title>RUZEE.Borders - Description</title>
<style><!--

body { background: #ffe; color: #111; }
.rbex { background: #aa8; padding: 20px; margin: 10px; border: solid 2px #00e; color: #ffe}
.rbex { width: 80%; }
.rbbgimg { background: url(bgimg.gif) #CEDEA5; padding: 10px; } 

//-->
</style>

<script type="text/javascript" src="cssquery2.js"></script>
<script type="text/javascript" src="ruzeeborders.js"></script>
<script type="text/javascript"><!--
  window.onload=RUZEE.Borders.render;
//--></script>

</head>
<body>
<h2>RUZEE.Borders</h2>
<p/><script type="text/javascript"><!--//
function demo(s){//
  eval('RUZEE.Borders.add({'+s+'});');//
  document.writeln(s);//
};//
//--></script><p>RUZEE.Borders, formerly known as RuzeeBorders, is the first and only JavaScript library for rendering shadows and anti-aliased rounded corners inside a web browser without the designer needing to create background images. You can easily include it into your web site/blog etc. with only minor knowledge about JavaScript.</p>
<h3>Features</h3>
<ul>
<li>Border style definition via CSS and CSS-like JavaScript</li>
<li>Anti-aliased rounded corners similar to the successors of <a href="http://pro.html.it/esempio/nifty/">Nifty Corners</a></li>
<li>A symmetric shadow similar to the ones of Mac OS X</li>
<li>Configurable border widths</li>
<li>Outside as well as inside background image support (gradients)</li>
<li>A kind of glow which is based on the shadow feature with a configurable color</li>
<li>A fade effect which lets the border color fade into the background color</li>
<li>All that at every edge/corner or only at some of them</li>
<li>Works on all modern browsers, even Opera and Konqueror</li>
<li>Colors and layout of the borders are defined in the CSS - if JavaScript is disabled your web site looks like its cubistic twin ;-)</li>
</ul>

<h3>Supported Browsers</h3>
<p>These are the browser I'm testing my releases with (and others may work as well):</p>
<ul>
<li>Internet Explorer 6.0</li>
<li>Firefox 1.5</li>
<li>Safari 2</li>
<li>Opera 9</li>
<li>KDE Konqueror 3.5</li>
</ul>

<h3>Usage</h3>
<p>When rendering borders, CSS is used for all border style settings that can be definied via standard means. These are: border-width, border-color, etc. Here's an example CSS fragment:</p>
<pre>
#myborder: {
  border: 2px solid red;
  background: blue;
  padding: 10px;
}
</pre>

<p>If you have an HTML element with the ID 'myborder' in your HTML document, it will show up blue with a 3px wide, red solid border. This is the standard CSS way and works without RUZEE.Borders (of course ;-)). Make sure to always apply some padding, because RUZEE.Borders will "eat" some of it!</p>

<p>All style settings that are not available in the current CSS standard, i.e. everything that RUZEE.Borders need to round, shadow, glow, etc., have to be set via a CSS-like JavaScript code fragment in your page. Check out <a href="http://www.ruzee.com/blog/2006/06/a-tutorial-for-rounded-corners-with-drop-shadows/">the tutorial</a> or the example HTML file for details on how to do that (included in the download ZIP file). For now, have a look at the following examples - the borders you see are rendered by the definition inside - the value before the colon is a <a href="http://www.w3.org/TR/REC-CSS2/selector.html">CSS selector</a>, the values after it the style settings.</p>

<p>Draw a simple border with the corner radius of 4 pixels around the HTML element with the ID 'rbex1':</p>
<div id="rbex1" class="rbex">
<script type="text/javascript"><!--//
demo("'#rbex1': { borderType:'simple', cornerRadius:4 }");//--></script>
</div>

<p>Draw a glowing border with an edge radius of 4 pixels and a blueish glow that has a width of 5 pixels around the elements with the ID 'rbex2':</p>
<div id="rbex2" class="rbex">
<script type="text/javascript"><!--//
demo("'#rbex2': { borderType:'glow', cornerRadius:4, glowWidth:5, glowColor:'#35e' }");//--></script>
</div>

<p>Draw a border with a corner radius of 4 pixels and a shadow with the width of 5 pixels around the element with the ID 'rbex3':</p>
<div id="rbex3" class="rbex">
<script type="text/javascript"><!--//
demo("'#rbex3': { borderType:'shadow', cornerRadius:4, shadowWidth:5 }");//--></script>
</div>

<p>Draw a border with a corner radius of 8 pixels that fades out to the color of the background around the element with the ID 'rbex4':</p>
<div id="rbex4" class="rbex" style="border: none; background: #35e;">
<script type="text/javascript"><!--//
demo("'#rbex4': { borderType:'fade', cornerRadius:8 }");//--></script>
</div>
  
<p>Draw a simple border, but round only the left/right bottom ('l'=left, 'r'=right, 'b'=bottom):</p>
<div id="rbex5" class="rbex">
<script type="text/javascript"><!--//
demo("'#rbex5': { borderType:'simple', cornerRadius:4, edges:'lrb' }");//--></script>
</div>
  
<p>Draw a simple border, but round only the left on bottom/top bottom ('l'=left, 't'=top, 'b'=bottom):</p>
<div id="rbex6" class="rbex">
<script type="text/javascript"><!--//
demo("'#rbex6': { borderType:'simple', cornerRadius:4, edges:'ltb' }");//--></script>
</div>

<p>Draw a simple border, but round only the top left corner ('l'=left, 't'=top):</p>
<div id="rbex7" class="rbex">
<script type="text/javascript"><!--//
demo("'#rbex7': { borderType:'simple', cornerRadius:4, edges:'lt' }");//--></script>
</div>

<p>All borders can have a background image inside. It will be aligned to the top and can only be drawn inside the upper border. But together with repeat-x, this limitation isn't as bad as it seems - it's perfect for all those nifty Web 2.0 style gradients ;-). This example shows, that the image is really in the top of the border - clear gradients are possible this way.</p>
<div id="rbex8" class="rbex rbbgimg">
<script type="text/javascript"><!--//
demo("'#rbex8': { borderType:'shadow', cornerRadius:6, shadowWidth:6 }");//--></script>
</div>

<p>Simple borders can be put on top of a background image using pseudo-transparency. I've decided to not use the CSS3 opacity or similar techniques due to the reasons described <a href="http://www.ruzee.com/blog/2006/04/support-for-opacity-in-modern-browser/">here</a>, which means that you have to set a background color "similar" to the color of your background image:</p>

<div class="rbbgimg"><div id="rbex9" class="rbex">
<script type="text/javascript"><!--//
demo("'#rbex9': { borderType:'simple', cornerRadius:6 }");//--></script>
</div></div>

<p>As you can see, you do not need to specify any color values at all for the border, background, etc. only for the glow where there is no CSS style value that could be "misused" for that issue...</p>

<p>In the examples above, only ID based CSS selectors were used. The library included supports all the things you know from CSS and more (have a look at the credits section).</p>

<h3>Download</h3>
<p>Feel free to download <a href="http://www.ruzee.com/files/ruzeeborders-0.16.1.zip">RUZEE.Borders v0.16.1</a>. The license is included in the archive, it's MIT-style. Have fun playing around with the lib and if you have any suggestions, bug fixes, etc. please comment at the end of this page.</p>

<h3>Credits</h3>
<p>For the CSS-like selection of DOM elements, I'm using a CSS level 2 customized version of Dean Edwards' <a href="http://dean.edwards.name/my/cssQuery/">cssQuery</a>, thanks for this cool piece of code!</p>
<p>I'm also using a <a href="http://www.phpied.com/rgb-color-parser-in-javascript/">JavaScript CSS color converter</a> that I stripped down to my requirements - cheers go to Stoyan Stefanov for that.</p>

<h3>Tips and Tricks</h3>
<p>To speed up the loading time of your page, especially if there are lots of images or IFRAME ads (e.g. Google), use the domload event of <a href="http://www.ruzee.com/blog/ruzeeevents/">RUZEE.Events</a>.</p>
<p>If you are using the <a href="http://code.google.com/webtoolkit/">Google Web Toolkit</a> and want to add rounded corners to your site, check out the RUZEE.Borders based <a href="http://gwt.components.googlepages.com/roundcorners">rounded corners component</a> by Alexei Sokolov.</p>
<p>Internet Explorer displays a page very soon. If you want a blank page till RUZEE.Borders finished rendering, add the following lines to your page code:</p>
<pre>
CSS (hides HTML body when JavaScript is enabled):
* html body { display:expression('none'); }

HTML/body.onload():
RUZEE.Borders.render(function(){
  // rendering finished, now show the body
  document.body.style.display='block';
});
</pre>
<p>You can instantiate RUZEE.Borders.Border directly and call its render() method, if you know the DOM elements you want to put borders around. That's ideal for 3rd party libs using RUZEE.Borders (e.g. GWT, hint!!! ;-)).</p>
<p>For "askew" corners, e.g. let only top-left and bottom-right be rounded, but the other two right angle, have a look at the <a href="http://www.ruzee.com/files/emad-ex/">Emad Workaround</a>.</p>
<p>A nice design idea came from Simon - put your inner title <a href="http://www.ruzee.com/files/simon-ex/">on top of your corners</a>.</p>

<h3>Known Bugs and Limitations</h3>
<p>Quirks Mode is not supported.</p>
<p>!!! Floated elements inside a rounded border have to be positioned relatively (i.e. style="float:left; position:relative;") !!! Not doing so will mess up Internet Explorer's rendering completely (The <a href="http://www.positioniseverything.net/explorer/peekaboo.html">Peekaboo Bug</a> is responsible for that).</p>
<p>If you want a DIV with a fixed height, heights have to be specified via CSS <b>and</b> the height attribute of a RUZEE.Border (via <code>RUZEE.Borders.add(...)</code>), because the height of a DIV cannot be read from the CSS properties reliably on all browsers.</p>
<p>Konqueror has a bug when getting the styles for an element. RUZEE.Borders try to calculate the background color recursively until they reach an element with a non-transparent background. Konqueror unfortunately returns #000000 when the background is transparent. Hence #000000 is interpreted as transparent. If you want a black background using #010101 in your CSS is a possible workaround - assuming "almost black" is ok for you (see also <a href="http://www.ruzee.com/blog/2006/07/retrieving-css-styles-via-javascript/">my blog posting on that issue</a>).</p>

<h3>Version History</h3>
<ul>
<li>v0.16.1 (2006-10-06):
  <ul>
  <li>Fix Safari.</li>
  </ul>
</li>
<li>v0.16 (2006-09-30):
  <ul>
  <li>Fix IE elements jump bug reported by Russ.</li>
  <li>Refactorings, made most of the internal methods really private.</li>
  </ul>
</li>
<li>v0.15 (2006-09-15):
  <ul><li>Loads of bug fixes with the newly introduced 0 padding feature of version 0.14 (overflow no longer needed, but take care of floated elements inside a rounded border, see limitations section). This should fix some of Adam's problems.</li></ul>
</li>
<li>v0.14 (2006-08-25):
  <ul>
  <li>The top border gets anti-aliased even when a background image is set. Looks better with most gradients.</li>
  <li>Add the "Jakob feature": Paddings can now be definied in em, in, cm, etc.. I'm heavily using negative margins now - please tell me if this makes any trouble (see Limitations section). One side effect: You don't have to use paddings anymore and work with margins on your inner elements which is much cleaner.</li>
  <li>Removed Quirks Mode support.</li>
  </ul>
</li>
<li>v0.13 (2006-07-08):
  <ul>
  <li>Fix Chris' height bug - when the height definied in JavaScript was "too less", sometimes RUZEE.Borders tried to set a negative height which IE didn't like...</li>
  <li>Some clean-ups in the CSS style retrieval code.</li>
  </ul>
</li>
<li>v0.12 (2006-07-01):
  <ul>
  <li>The RUZEE.Borders.render() method is potentially asynchronous now. Fix the "unresposive script" error message of Firefox. If you need to do things AFTER the rendering finished, use the new onfinished parameter - that's a semantic change in the API, please be aware of that! This also applies to the IE "blank page" tip.</li>
  </ul>
</li>
<li>v0.11 (2006-06-04):
  <ul>
  <li>Widths of the bordered elements get no longer lost.</li>
  <li>Pixel heights can be specified via the "height" property in RUZEE.Borders.add().</li>
  <li><a href="/files/rbex/seb/">Seb's workaround</a> is no longer needed while still maintainig the <a href="/files/simon-ex/">simon feature</a>.</li>
  <li>Some speed optimizations.</li>
  </ul>
</li>
<li>v0.10.1 (2006-05-29):
  <ul>
  <li>Remove the ugly alert box in cssQuery...</li>
  </ul>
</li>
<li>v0.10 (2006-05-28):
  <ul>
  <li>A new CSS-like JavaScript based API has been introduced. It is much cleaner than the old API, especially when you are used to CSS. The old API is still available (backward compatible), but will probably be removed in future versions.</li>
  <li>Tweak the padding adjustment for borders that are only rendered top or bottom.</li>
  </ul>
</li>
<li>v0.9.1 (2006-05-21):
  <ul>
  <li>Remove a bug fix that broke the simon feature. The fix was for <a href="/files/rbex/seb/">Seb's problem</a> (ugly gaps between the top/bottom of the border), which now has to be solved via a workaround in the HTML source (see link).</li>
  </ul>
</li>
<li>v0.9 (2006-05-21):
  <ul>
  <li>Support for background images inside the border DIV, currently limited to repeat-x backgrounds at the top - which is perfect for Web 2.0 style gradients.</li>
  <li>Less DIVs are generated and no more floats are used, which speeds things up again and solves DarkAngle's problem (partly I guess...).</li>
  <li>Fix a bug when there was no background color set in for "inside the border" and also for no background color set anywhere outside the border on Firefox.</li>
  <li>The Firefox top right pixel jog bug no longer exists as RUZEE.Borders no longer use floated elements.</li>
  <li>Already in 0.8 but not documented: The .class based selection of elements now also works with IEs &lt;6.0.</li>
  </ul>
</li>
<li>v0.8 (2006-05-13):
  <ul>
  <li>Cache the corners already draw, reduce the number of DIVs -&gt; <a href="http://www.ruzee.com/blog/2006/05/draw-it-faster-dude/">speeeeed</a>! Cheers, Simon, for the hint.</li>
  <li>Cache for getElementsByClass (the .className feature). Source out into a seperate JavaScript file - please don't forget to include it!</li>
  <li>Documented the Firefox speed-up trick.</li>
  <li>First release under an MIT license.</li>
  </ul>
</li>
<li>v0.7.3 (2006-05-11):
  <ul>
  <li>Let the inner DIV no longer be "overflow:hidden" - fix the "Simon" bug.</li>
  </ul>
</li>
<li>v0.7.2 (2006-05-09):
  <ul>
  <li>Fix a NullPointerException in rzGetStyle - the "Lolita" bug ;-).</li>
  </ul>
</li>
<li>v0.7.1 (2006-05-05): only seconds after 0.7 ...
  <ul>
  <li>Bug fix for 0px borders (e.g. style="border:none") not having been anti-aliased correctly.</li>
  </ul>
</li>
<li>v0.7 (2006-05-05):
  <ul>
  <li>Support for border widths via the corresponding CSS property (e.g. style="border: 4px solid green").</li>
  <li>Bug fix for IE padding adjustment being 3 pixel off left and right when rendering non-simple borders without the top edge.</li>
  </ul>
</li>
<li>v0.6 (2006-04-26):
  <ul>
  <li>Support for pseudo-transparency of simple borders - usefull if you have a bordered element on top of a background image.</li>
  <li>Bug fix for HTML elements inside the border having margins splitting the border top and bottom (thanks to <a href="http://sebundchrissi.kicks-ass.net">Seb</a> for sending me the bug report and a test case).</li>
  <li>Removed support for Internet Explorer 5.0 - it got broken with one of the last releases and I just realized... Is there anyone missing it?</li>
  <li>Removed official support for Firefox 1.x due to the lack of an installed browser - it should work if it works on version 1.5...</li>
  </ul>
</li>
<li>v0.5 (2006-04-17): Changes are
  <ul>
  <li>The API has changed! The glow/shadow color is no longer passed via .draw(), but via the constructor (i.e. the rcCrXxx methods).</li>
  <li>Support for different edges to not being rounded. This is done via the .draw() method, e.g. it is possible to instantiate a border once but draw different edges with it.</li>
  <li>Added documentation for the fade feature (and did some clean-ups before).</li>
  </ul>
</li>
<li>v0.4 (2006-03-31): Back to the old versioning scheme - forget about 0.30 ;-) Changes:
  <ul>
  <li>No more "flipping" - RuzeeBorder now leaves the layout as it is by modifying the padding of your DIVs. This results in a much cleaner site impression. But... it seems to buggy on IE.</li>
  <li>Support for classes via ".classname" (rzGetElementsByClass is no longer needed, see example.html)</li>
  <li>Support for XHTML pages</li>
  </ul>
</li>
<li>v0.30 (2006-03-19): Workaround for Safari transparency (rgba color strings) which caused white backgrounds sometimes - Thanks to <a href="http://sebundchrissi.kicks-ass.net">Sebastian</a> for the VNC connection to his Mac mini.</li>
<li>v0.2 (2006-03-04): Fixes Internet Explorer 5.5 ("font-size: 1px;" hack) double height bug, a bug when using fixed widths (was an Internet Explorer issue), and a "NullPointerException"</li>
<li>v0.1 (2006-03-01): First release</li>
</ul>

<h3>Additional Information</h3>
Get the latest version of RUZEE.Borders at <a href="http://www.ruzee.com">Steffen Rusitschka's Blog</a>.

</body>